package com.dq.domain.org;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.sys.user.user.StaffUser;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @author liuhui
 * @date 2019/11/20 0020 10:41:29
 */
@Data
@Entity
@ApiModel("门店荣誉墙")
public class OrgHonorWall extends BaseEntity implements VO.ToVO {

    @ManyToOne
    @ApiModelProperty("门店")
    protected Org sysDept;

    @ManyToOne
    @ApiModelProperty("员工")
    protected StaffUser staffUser;

    @Data
    @ApiModel(value = "门店荣誉墙实体")
    public static class Vo implements VO {
        @ApiModelProperty("id")
        protected Long id;
        @ApiModelProperty("员工姓名")
        protected String userRealcName;
        protected Long staffUserId;
        @ApiModelProperty("门店荣誉墙员工照片")
        protected String honorWallStaffImage;
        @ApiModelProperty("门店荣誉墙员工描述")
        protected String honorWallInfomation;
        @ApiModelProperty("岗位名称")
        protected String postName;

        @ApiModelProperty(value = "创建时间")
        private String createTime;
        @ApiModelProperty(value = "修改时间")
        private String lastModifyTime;
        @ApiModelProperty(value = "创建者id")
        private Long createUserId;
        @ApiModelProperty(value = "创建者name")
        private String createUserName;
        @ApiModelProperty(value = "修改者id")
        private Long updateUserId;
        @ApiModelProperty(value = "修改者name")
        private String updateUserName;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.id;
        vo.userRealcName = this.staffUser.getUserRealcName();
        vo.staffUserId = this.getStaffUser().getId();
        vo.honorWallStaffImage = this.staffUser.getHonorWallStaffImage();
        vo.honorWallInfomation = this.staffUser.getHonorWallInfomation();
        vo.postName = this.staffUser.getOrgPosition()!=null?this.staffUser.getOrgPosition().getPostName():"";

        vo.createTime = TimeUtil.longToString(this.createTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.lastModifyTime = TimeUtil.longToString(this.lastModifyTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.createUserId = this.createUser == null ? null : this.createUser.getId();
        vo.createUserName = this.createUser == null ? null : this.createUser.getUsername();
        vo.updateUserId = this.updateUser == null ? null : this.updateUser.getId();
        vo.updateUserName = this.updateUser == null ? null : this.updateUser.getUsername();
        return vo;
    }

    @Data
    @ApiModel("荣誉墙视图")
    public static class OrgHonorWallVo{
        @ApiModelProperty("id")
        protected Long id;
        @ApiModelProperty("员工姓名")
        protected String localNickName;
        @ApiModelProperty("门店荣誉墙员工照片")
        protected String honorWallStaffImage;
        @ApiModelProperty("门店荣誉墙员工描述")
        protected String honorWallInfomation;
        @ApiModelProperty("岗位名称")
        protected String postName;
    }

    @Data
    @ApiModel("门店app荣誉墙列表视图")
    public static class OrgHonorWallListVo{
        @ApiModelProperty("荣誉墙id")
        protected Long id;
        @ApiModelProperty("用户荣誉墙头像")
        protected String imageUrl;
        @ApiModelProperty("用户真实姓名")
        protected String userRealcName;
        @ApiModelProperty("员工介绍")
        protected String description;
        @ApiModelProperty("用户id")
        protected Long userId;

    }

    public OrgHonorWallListVo toOrgHonorWallListVo(){
        OrgHonorWall.OrgHonorWallListVo orgHonorWallListVo = new OrgHonorWall.OrgHonorWallListVo();
        orgHonorWallListVo.id = this.getId();
        orgHonorWallListVo.userId = this.getStaffUser().getId();
        orgHonorWallListVo.imageUrl = fmt(this.getStaffUser().getHonorWallStaffImage());
        orgHonorWallListVo.description = fmt(this.getStaffUser().getHonorWallInfomation());
        orgHonorWallListVo.userRealcName = fmt(this.getStaffUser().getUserRealcName());
        return orgHonorWallListVo;
    }

    public OrgHonorWallVo toOrgHonorWallVo(){
        OrgHonorWallVo vo = new OrgHonorWallVo();
        vo.id = this.id;
        vo.localNickName = this.staffUser.getUserRealcName();
        vo.honorWallStaffImage = this.staffUser.getHonorWallStaffImage();
        vo.honorWallInfomation = this.staffUser.getHonorWallInfomation();
        vo.postName = this.staffUser.getOrgPosition().getPostName();
        return vo;
    }
}
